package com.itheima.demo01;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ServicerClass {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10013);
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                2,
                5,
                30,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(5),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        while (true) {
            Socket accept = ss.accept();
            RunnableSocket rs = new RunnableSocket(accept);
            pool.submit(rs);
        }

//        accept.close();
    }
}
